<%--
  寄养家庭列表页面
  展示可提供寄养服务的家庭信息
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宠物邻里互助平台</title>
    <style>
        /* 寄养家庭卡片样式 */
        .family-card {
            background-color: var(--white);
            border-radius: var(--radius-md);
            padding: 0;
            transition: var(--transition);
            border: 1px solid var(--primary-light);
            box-shadow: var(--shadow-sm);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        /* 价格标签样式 */
        .price {
            font-weight: bold;
            color: var(--primary-dark);
            font-size: 20px;
            display: flex;
            align-items: center;
        }

        /* 预约按钮样式 */
        .book-btn {
            background: linear-gradient(to right, var(--primary-color), var(--primary-dark));
            color: var(--white);
            border: none;
            border-radius: 20px;
            padding: 10px 25px;
            cursor: pointer;
            transition: var(--transition);
            font-weight: 600;
            box-shadow: var(--shadow-sm);
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body>

<!-- 引入公共头部 -->
<jsp:include page="head.jsp"/>
<div class="container">
    <h1><i class="fas fa-paw"></i> 可寄养家庭</h1>

    <!-- 成为寄养家庭按钮 -->
    <div style="text-align: center; margin-bottom: 20px;">
        <a href="${pageContext.request.contextPath}/Hosts/publish" class="become-host-btn">
            <i class="fas fa-home"></i> 成为寄养家庭
        </a>
    </div>

    <!-- 搜索和筛选表单 -->
    <form id="searchForm" action="${pageContext.request.contextPath}/Hosts/search" method="get">
        <div class="search-bar">
            <input type="text" name="family_name" placeholder="搜索寄养家庭..." value="${param.family_name}">
            <button type="submit"><i class="fas fa-search"></i> 搜索</button>
        </div>
    </form>

    <!-- 寄养家庭列表 -->
    <div class="foster-families">
        <c:forEach items="${hostList}" var="family">
            <div class="family-card">
                <!-- 家庭信息展示 -->
                <div class="family-footer">
                    <div class="price">${family.price}元/天</div>
                    <button onclick="bookFamily(${family.family_id}, '${family.service_types}')" class="book-btn">
                        <i class="fas fa-calendar-check"></i> 立即预约
                    </button>
                </div>
            </div>
        </c:forEach>
    </div>
</div>

<script>
    // 预约寄养功能
    function bookFamily(familyId, serviceType) {
        window.location.href = '${pageContext.request.contextPath}/order/create?family_id=' + familyId + '&service_type=' + encodeURIComponent(serviceType);
    }
</script>
</body>
</html>